package org.xlp.auto.create;

import org.xlp.auto.create.exception.AutoCreatorDataLoseException;

import java.io.IOException;

/**
 * Description:
 * <br/>date: 2023/12/4 16:46
 *
 * @version 1.0
 * @author: xlp
 */
public class DaoGroupAutoCreator extends AbstractGroupAutoCreator{
    private final DaoAutoCreator autoCreator;

    private DaoImplAutoCreator daoImplAutoCreator;

    public DaoGroupAutoCreator() {
        autoCreator = new DaoAutoCreator();
    }

    /**
     * 构造函数
     *
     * @param abstractAutoCreator
     * @throws NullPointerException 假如参数为null，则抛出该异常
     */
    public DaoGroupAutoCreator(AbstractAutoCreator abstractAutoCreator) {
        autoCreator = new DaoAutoCreator(abstractAutoCreator);
    }

    /**
     * java文件注解类容
     *
     * @return
     */
    @Override
    protected String makeAnnotationContent() {
        return null;
    }

    /**
     * 获取java文件名称
     *
     * @return
     * @throws AutoCreatorDataLoseException 假如获取失败，则抛出该异常
     */
    @Override
    protected String getFileName() throws AutoCreatorDataLoseException {
        return null;
    }

    @Override
    public String getRootPath() {
        return autoCreator.getRootPath();
    }

    /**
     * 设置根目录
     *
     * @param rootPath
     * @throws NullPointerException 假如参数为null，则抛出该异常
     */
    @Override
    public void setRootPath(String rootPath) {
        autoCreator.setRootPath(rootPath);
    }

    @Override
    public boolean isMikRootPath() {
        return autoCreator.isMikRootPath();
    }

    @Override
    public void setMikRootPath(boolean mikRootPath) {
        autoCreator.setMikRootPath(mikRootPath);
    }

    @Override
    public String getEntityName() {
        return autoCreator.getEntityName();
    }

    /**
     * 设置实体名称
     *
     * @param entityName
     * @throws NullPointerException 假如参数为null，则抛出该异常
     */
    @Override
    public void setEntityName(String entityName) {
        autoCreator.setEntityName(entityName);
    }

    @Override
    public String getRootPackageName() {
        return autoCreator.getRootPackageName();
    }

    @Override
    public void setRootPackageName(String rootPackageName) {
        autoCreator.setRootPackageName(rootPackageName);
    }

    @Override
    public String getSubPackageName() {
        return autoCreator.getSubPackageName();
    }

    @Override
    public void setSubPackageName(String subPackageName) {
        autoCreator.setSubPackageName(subPackageName);
    }

    @Override
    public String getSupperClassName() {
        return autoCreator.getSupperClassName();
    }

    @Override
    public void setSupperClassName(String supperClassName) {
        autoCreator.setSupperClassName(supperClassName);
    }

    @Override
    public String[] getInterfaceNames() {
        return autoCreator.getInterfaceNames();
    }

    @Override
    public void setInterfaceNames(String[] interfaceNames) {
        autoCreator.setInterfaceNames(interfaceNames);
    }

    @Override
    public String getVersion() {
        return autoCreator.getVersion();
    }

    @Override
    public void setVersion(String version) {
        autoCreator.setVersion(version);
    }

    @Override
    public String getAuthor() {
        return autoCreator.getAuthor();
    }

    @Override
    public void setAuthor(String author) {
        autoCreator.setAuthor(author);
    }

    @Override
    public ClassType getClassType() {
        return autoCreator.getClassType();
    }

    @Override
    public void setClassType(ClassType classType) {
        autoCreator.setClassType(classType);
    }

    /**
     * Java文件导入包内容
     *
     * @return
     */
    @Override
    protected String makeImportContent() {
        return null;
    }

    /**
     * 添加要实现的接口名称
     *
     * @param interfaceName
     */
    @Override
    public void addInterfaceName(String interfaceName) {
        autoCreator.addInterfaceName(interfaceName);
    }

    /**
     * java文件 类描述信息
     *
     * @return
     */
    @Override
    protected String makeDescriptionContent() {
        return null;
    }

    /**
     * java文件对应的类主体内容
     *
     * @return
     */
    @Override
    protected String makeBodyContent() {
        return null;
    }

    /**
     * 制作文件类容
     *
     * @return
     * @throws AutoCreatorDataLoseException 假如所需数据缺少，则抛出该异常
     */
    @Override
    protected String makeFileContent() throws AutoCreatorDataLoseException {
        return null;
    }

    /**
     * 写文件
     *
     * @throws IOException
     * @throws AutoCreatorDataLoseException 假如所需数据缺少，则抛出该异常
     */
    @Override
    public void write() throws IOException, AutoCreatorDataLoseException {
        autoCreator.write();
        getDaoImplAutoCreator().write();
    }

    public DaoAutoCreator getAutoCreator() {
        return autoCreator;
    }

    public DaoImplAutoCreator getDaoImplAutoCreator() {
        if (daoImplAutoCreator == null) {
            daoImplAutoCreator = new DaoImplAutoCreator(autoCreator);
            daoImplAutoCreator.setSupperClassName(getSupperClassNameForImpl());
            daoImplAutoCreator.setInterfaceNames(getInterfaceNamesForImpl());
            daoImplAutoCreator.setClassType(getClassTypeForImpl());
        }
        return daoImplAutoCreator;
    }
}
